<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/core"%>
<div class="layui-header">
	<div class="layui-logo" style="color: #fff">N6_1F储位管理</div>
	<!-- 头部区域（可配合layui已有的水平导航） -->
	<ul class="layui-nav layui-layout-left">
		<li class="layui-nav-item"><a href=""></a></li>
		<li class="layui-nav-item">
			<a href="javascript:;">
				Summary
			</a>
			<dl class="layui-nav-child">
				<dd>
					<a href="${base }/summary/auto/index3.html">Summary</a>
				</dd>
				<dd>
					<a href="${base }/summary/auto/xjxc.html">Summary 自动 - 先进先出</a>
				</dd>
				<dd style="display:none">
					<a href="${base }/summary/auto/index.html">Summary 自动 - 原来的</a>
				</dd>
				<dd>
					<a href="${base }/summary/auto/index1.html">Summary 自动 - 全部</a>
				</dd>
				<dd>
					<a href="${base }/summary/auto/index2.html">Summary 自动 - 条件</a>
				</dd>
				<dd>
					<a href="${base }/summary/hm/index.html">Summary 手动</a>
				</dd>
			</dl>
		</li>
		<li class="layui-nav-item">
				<a href="javascript:;">
					Details
				</a>
				<dl class="layui-nav-child">
					<dd>
						<a href="${base }/N6_1F/Chuwei/Details/auto/list.html">Details 自动</a>
					</dd>
					<dd>
						<a href="${base }/N6_1F/Chuwei/details/hm/list.html">Details 手动</a>
					</dd>
				</dl>
			</li>
	</ul>
	<s:if test="${sessionScope.user != null }">
		<ul class="layui-nav layui-layout-right">
			<li class="layui-nav-item">
				<a href="${base }/N6_1F/Chuwei/Details/auto/biangeng.html">
					储位变更
				</a>
			</li>
			<li class="layui-nav-item">
				<a href="javascript:;">
					In 登记
				</a>
				<dl class="layui-nav-child">
					<dd style="display:none">
						<a href="${base }/N6_1F/Chuwei/summary/in.html">Summary</a>
					</dd>
					<dd>
						<a href="${base }/N6_1F/Chuwei/Details/auto/xjxcin">先进先出</a>
					</dd>
					<dd>
						<a href="${base }/N6_1F/Chuwei/details/auto/in.html">Details 自动</a>
					</dd>
					<dd>
						<a href="${base }/N6_1F/Chuwei/details/hm/in.html">Details 手动</a>
					</dd>
				</dl>
			</li>
			<li class="layui-nav-item">
				<a href="javascript:;">
					Out 登记
				</a>
				<dl class="layui-nav-child">
					<dd style="display:none">
						<a href="${base }/N6_1F/Chuwei/summary/out.html">Summary</a>
					</dd>
					<dd>
						<a href="${base }/N6_1F/Chuwei/details/auto/out.html">Details 自动</a>
					</dd>
					<dd>
						<a href="${base }/N6_1F/Chuwei/details/auto/outByChuwei.html">Details 自动 - 按储位OUT</a>
					</dd>
					<dd>
						<a href="${base }/N6_1F/Chuwei/details/hm/out.html">Details 手动</a>
					</dd>
				</dl>
			</li>
			<li class="layui-nav-item">
				<a href="javascript:;">
					用户操作
				</a>
				<dl class="layui-nav-child">
					<dd>
						<a href="#" onclick="changeInfoAlertEvent()">更改资料</a>
					</dd>
					<dd>
						<a href="#" onclick="changePsdAlertEvent()">更改密码</a>
					</dd>
					<dd>
						<a href="${base }/user/logout.html">溜了先</a>
					</dd>
				</dl>
			</li>
		</ul>
	</s:if>
	<s:if test="${sessionScope.user == null }">
		<ul class="layui-nav layui-layout-right">
			<li class="layui-nav-item"><a href="${base }/user/login.html">登录</a></li>
		</ul>
	</s:if>
</div>
<form id="changePsdAlert" class="layui-form" action=""
	style="margin: 5px; display: none" lay-filter="changePsdForm">
	<input type="hidden" name="id" value="${sessionScope.user.id }"/>
	<div class="layui-form-item">
		<label class="layui-form-label">旧密码</label>
		<div class="layui-input-block">
			<input type="text" name="oldPassword" required lay-verify="required"
				placeholder="请输入旧密码" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">新密码</label>
		<div class="layui-input-block">
			<input type="text" name="newPassword" required lay-verify="required"
				placeholder="请输入新密码" autocomplete="off" class="layui-input">
		</div>
	</div>
	
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn" lay-submit lay-filter="changePsd">更改</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
</form>
<form id="changeInfoAlert" class="layui-form" action=""
	style="margin: 5px; display: none" lay-filter="changeInfoForm">
	<input type="hidden" name="id" value="${sessionScope.user.id }"/>
	<div class="layui-form-item">
		<label class="layui-form-label">工号</label>
		<div class="layui-input-block">
			<input type="text" name="no" required lay-verify="required"
				placeholder="请输入工号" autocomplete="off" class="layui-input" value="${sessionScope.user.no }">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">姓名</label>
		<div class="layui-input-block">
			<input type="text" name="username" required lay-verify="required"
				placeholder="请输入姓名" autocomplete="off" class="layui-input" value="${sessionScope.user.username }">
		</div>
	</div>
	
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn" lay-submit lay-filter="changeInfo">更改</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
</form>
<script type="text/javascript">
	$(function(){
		layui.form.on("submit(changePsd)", function(data){
			$.ajax({
	        	url:"${base}/api/user/changePassword",
	        	type: "post",
	        	data: data.field,
	        	success: function(result){
	        		if(result.code == 1001){
	        			layer.msg(result.msg, {icon:6});
	        		}else{
	        			layer.msg(result.msg, {icon:5,anim:6});
	        		}
	        	}
	        });
			return false;
		})
		layui.form.on("submit(changeInfo)", function(data){
			$.ajax({
	        	url:"${base}/api/user/update",
	        	type: "post",
	        	data: data.field,
	        	success: function(result){
	        		if(result.code == 1001){
	        			layer.msg(result.msg, {icon:6});
	        			setTimeout(function(){
	        				location.reload();
	        			}, 800);
	        		}else{
	        			layer.msg(result.msg, {icon:5,anim:6});
	        		}
	        	}
	        });
			return false;
		})
	})
	
	function changePsdAlertEvent(){
		layer.open({
			type: 1,
			content: $('#changePsdAlert'),
			area: '500px',
			cancel: function(e){
				$("#changePsdAlert").hide();
			}
		});
	}
	function changeInfoAlertEvent(){
		layer.open({
			type: 1,
			content: $('#changeInfoAlert'),
			area: '500px',
			cancel: function(e){
				$("#changeInfoAlert").hide();
			}
		});
	}
</script>